var $currentLi;
var topFrame = self.parent.topFrame;
var mainFrame = self.parent.mainFrame;

function setState(currentHref){
	var stateDl = '';
	$('#leftMenu dl').each(function(i,n){
			stateDl += n.className+'|';
	});
	cookieHandler('stateDl',stateDl,{path:'/'});
	cookieHandler('currentHref',currentHref,{path:'/'});
}

window.onerror = function(){return true;};
$(function($){
	$('#leftMenu dt').click(function(){
		var $this = $(this),_up=true,_down=true;
		var $parent = $this.parent('dl');
		if($parent.hasClass('current')){
			$this.nextAll('dd').slideUp("fast",function(){
				if(_up){
					_up = false;
					$parent.removeClass('current');
				}
			});
		}else{
			$('dl.current > dd').slideUp('fast',function(){
				if(_up){
					_up = false;
					$(this).parent('dl').removeClass('current');
				}
			});
			$this.nextAll('dd').slideDown("fast",function(){
				if(_down){
					_down = false;
					$parent.addClass('current');
				}
			});
			/*
			$('#leftMenu > dl').removeClass();
			$parent.addClass('current');*/
		}
	});
	$('#leftMenu dd > h2').click(function(){
		var $parent = $(this).parent('dd');
		$(this).next('ul').slideToggle('normal',function(){
			if($parent.hasClass('current'))
				$parent.removeClass('current');
			else
				$parent.addClass('current');
		});
	});

	$currentLi = $('#leftMenu li.current');
	$('#leftMenu li a').click(function(){
		setState($(this).attr('href'));
		var $parent = $(this).parent();
	
		if($currentLi)
			$currentLi.removeClass();
		$currentLi = $parent;
		$currentLi.addClass('current');
		mainFrame.loading();
		/*
		if($(this).attr('href') != '#')
			mainFrame.location=this;
		*/
//		topFrame.setSubNav($parent.parents('dd').prev('dt').text(),$(this).html());
		if($(this).attr('href') == '#')
			return false;
	});
})
/*
window.onload = function(){
	if(__redirect){
			$('#leftMenu li a').each(function(){
				var _this = this;
				var $this = $(this);
				if($this.attr('href') == __redirect){
					$currentLi.removeClass('current')
					$currentLi = $this.parent('li');
					$currentLi.addClass('current');
					__current[0] = _this;
					__current[1] = $this.parents('dd').prev('dt').text();
					__current[2] = $this.html();
					return false;
				}
			});
			mainFrame.onload = function(){
				mainFrame.loading();
				topFrame.setSubNav(__current[1],__current[2]);
				mainFrame.location = __current[0];
			}
	}else{
		setState(__current[0]);
		mainFrame.loading();
		topFrame.setSubNav(__current[1],__current[2]);
		mainFrame.location = __current[0];
	}
}*/